package com.xxx.auth.web.controller;

import com.xxx.auth.common.web.dto.ResultDTO;
import com.xxx.auth.service.UserService;
import com.xxx.auth.web.vo.RegisterForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/user")
@Tag(name = "用户接口")
@RequiredArgsConstructor
@Slf4j
public class UserController {

    private final UserService userService;

    @PostMapping("/register")
    @Operation(summary = "注册")
    @ApiResponse(responseCode = "200", description = "请求成功返回代码200，其它代码表示失败")
    public ResultDTO register(@RequestBody @Validated RegisterForm form) {
        return ResultDTO.success(userService.register(form));
    }

}
